#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
@Author: 李吉凯
@Email: lijk34925@hundsun.com
@Time: 2022/8/11 9:28
@File: app_fast.py
"""
import os
import re

import uvicorn
from fastapi import FastAPI
from starlette.staticfiles import StaticFiles

# from FastApi.src.Plat.xiaoNengPlatView import router as plat_router
from routes.bladeCaseView import router as case_router
from routes.amlEvnView import router as aml_evn_router
from routes.maxKbView import router as ai_router


app = FastAPI(title='数据风险测试服务', description='数据风险测试服务')

# 静态文件服务（可选，用于服务前端资源）
app.mount("/static", StaticFiles(directory="static"), name="static")

# 引入子路由
# app.include_router(plat_router, prefix='/plat')
app.include_router(case_router, prefix='/case')
app.include_router(aml_evn_router, prefix='/env')
app.include_router(ai_router, prefix='/ai')


if __name__ == '__main__':
    cur_file = os.path.abspath(__file__)
    cur_file_path = os.path.split(cur_file)[0]
    os.chdir(cur_file_path)
    print(f'cur path : {os.getcwd()}')
    hui_blade_frame = '../databases/driver'
    test_path = "../DataTest/tabledata" if re.search(r"web应用", cur_file_path, re.I) else "DataTest/tabledata"
    os.environ['TestDataPath'] = os.path.join(cur_file_path, test_path)
    uvicorn.run(app="app_fast:app", host="0.0.0.0", port=8015, reload=False, debug=False)
